<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Users_model extends CI_Model {
    
    function Users_model()
    {
        parent::__construct();
    }
    
    function check_username($username)
    {
        $this->db->where('username', $username);
        $query = $this->db->get('users');
        
        return $query->num_rows();
    }
    
    function register($insert)
    {
        $this->db->insert('users', $insert);
    }
    
    function login()
    {
        // Check if the user is logged in
        if($this->session->userdata('user_id'))
        {
            // Redirect to the accession grid
            redirect(base_url() . 'grid/');
        }
        // Otherwise, continue to load the login page
        
        // Prepare the required data for the header
        $data['title'] = 'Login';
        
        // Load the header
        $this->load->view('header_view', $data);
        
        // Load the footer
        $this->load->view('footer_view');
    }
    
}

/* End of file users_model.php */
/* Location: ./application/models/users_model.php */